// 处理业务逻辑的中间件,读取某个json文件的数据
const path = require('path')
const fileUtil = require('../utils/file_util')
module.exports = async (ctx, next) => {
    //根据url
    const url = ctx.request.url
    let filepath = url.replace('/api', '../data') + '.json'
    filepath = path.join(__dirname, filepath)
    const ret = await fileUtil.getFileJsonData(filepath)
    ctx.response.body = ret
    console.log(filepath);
    await next()
}